extends Area2D

@export var slime_speed :float = -100
var is_dead :bool = false
@export var slime_health :float = 10

func _physics_process(delta: float) -> void:
	if not is_dead:
		position += Vector2(slime_speed,0)*delta
	
	if position.x < -268 :
		queue_free()
	
	if slime_health <= 0:
		is_dead = true
		$AnimatedSprite2D.play("death")
		
		$enemydeath.play()
		get_tree().current_scene.score += 1
		
		await get_tree().create_timer(0.6).timeout
		queue_free()



func _on_area_entered(area: Area2D) -> void:
	if area.is_in_group("bullet"):
		var hurt = area.bullet_hurt
		area.queue_free()
		slime_health -= hurt
		





func _on_body_entered(body: Node2D) -> void:
	if body is CharacterBody2D:
		body.game_over()
